package com.tougutips.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.tougutips.common.redis.service.RedisService;
import com.tougutips.common.utils.StringUtil;
import com.tougutips.entity.Goods;
import com.tougutips.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService extends ServiceImpl<GoodsMapper, Goods> implements IService<Goods> {

    @Autowired
    private RedisService redisService;

    public List<Goods> list(){
        List<Goods> goodsList = redisService.getCacheList("goodsList");
        if(StringUtil.isNotEmpty(goodsList) && goodsList.size()<=0){
            return super.list();
        }
        return goodsList;
    }
}
